<template>
  <!-- 分页 -->
  <el-pagination
    @size-change="handleSizeChange"
    @current-change="searchPagniItem"
    :current-page.sync="searchObj.currpage"
    :page-sizes="[10, 20, 50, 100]"
    :page-size="searchObj.pagelines"
    :page-count="4"
    layout="prev, pager, next, total, sizes"
    background
    :total="pagniArr.rowCount ? pagniArr.rowCount : 0"
    :key="paginationKey"
  ></el-pagination>
</template>
  <script>
export default {
  name:'pagination_item',
  data() {
    return {
      searchObj: {
        currpage: 1,
        pagelines: 10,
      },
      paginationKey:''
    };
  },
  props: {
    pagniArr: {
      default: {},
    },
    pagniObj: {
      default: {},
    },
  },
  created() {
    this.paginationKey=new Date().getTime()
  },
  watch: {
    pagniObj: {
      handler(value) {
        this.searchObj = Object.assign({}, this.searchObj, { currpage: value.currpage, pagelines: value.pagelines })
        this.paginationKey=new Date().getTime()
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    searchPagniItem() {
      this.$emit("searchPagniItem", this.searchObj);
    },
    handleSizeChange(size) {
      this.searchObj.pagelines = size;
      this.searchPagniItem();
    },
  },
};
</script>